<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .clear{
            clear:both;
        }
        .box1{
            width: 200px;
            height: 200px;
            background-color: #f00;
            float: left;
        }
        .box2{
            width: 200px;
            height: 200px;
            background-color: #0f0;
            float: left;
        }
        .nav_clear::before,.nav_clear::after{
            content: "";
            display: block; /*将伪元素增加的内容设置为块元素*/
            clear:both;
        }
    </style>
</head>
<body>
    <div>
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="clear"></div>
    </div>
    <h3>浮动元素下面的元素</h3>
    <div class="nav_clear">
        <div class="box1"></div>
        <div class="box2"></div>
    </div>
    <h3>浮动元素下面的元素</h3>
</body>
</html>
